var express = require('express');
var router = express.Router();
const goodsController = require('../controllers/repair_controller');
const  cart =require('../models/repair_bean')

//增加维修记录
router.post('/addrepair', function (req, res) {
    console.log();
    goodsController.addrepair(new cart.add(req.body.data),(ret) =>res.json(ret)
    ,
    (err) => res.json(err)
    )
})

//获取维修数据
router.post('/selectall', function (req, res) {
    console.log(req.body.page,req.body.size);
    goodsController.getrepair(new cart.select(req.body.page,req.body.size),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})
//查询单条数据
router.post('/select', function (req, res) {
    goodsController.getlist(new cart.list(req.body.field,req.body.input),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})




//删除数据
// router.delete('/deleterepair', function (req, res) {
//     console.log(req.body.userid,req.body.qty);
//    goodsController.deleterepair(new cart.deltete(req.body.userid,req.body.goodsid),(ret) =>res.json(ret)
//     ,
//        (err) => res.json(err)
//    )
// })


//修改数据
router.put('/updatarepair', function (req, res) {
    console.log(req.body.id,req.body.data);
    goodsController.updaterepair(new cart.update(req.body.id,req.body.data),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})


module.exports =router